# 1.模拟鼠标移动
# 2.执行js代码
# driver.execute_script()
# 让元素滚到屏幕正中间：driver.execute_script("arguments[0],scrollIntoView({block:'center',inline:'center'})",ele)
# 3.冻结画面
# setTimeout(function(){debugger},5000) 直接在浏览器中的concolse执行
# 4.点击确认
# driver.switch_to.alert.text
# driver.switch_to.alert.accept()
# driver.switch_to.alert.dismiss()
# driver.switch_to.alert.send_keys()
# 5.窗口大小
# driver.get_window_size()
# driver.set_window_size()
# driver.title
# driver.current_url
# 6.截屏
# driver.get_screenshot_as_file('1.png')
# 7.上传文件  对于input按钮，type为file send_keys()
# 8.自动化手工打开的chrome浏览器  :http://vip3.byhy.net/auto/selenium/skills_2/#_2

from selenium import webdriver
from selenium.webdriver.common.by import By
from changliang import LUJING
from selenium.webdriver.chrome.service import Service
import time

driver = webdriver.Chrome(service=Service(LUJING))
driver.implicitly_wait(5)

# driver.get('https://www.baidu.com/')

# from selenium.webdriver.common.action_chains import ActionChains

# ac = ActionChains(driver)

# # 鼠标移动到 元素上
# ac.move_to_element(
#     driver.find_element(By.CSS_SELECTOR, '[name="tj_briicon"]')
# ).perform()
# time.sleep(3)


#  把元素移到正中心
# driver.get('http://vip3.byhy.net/auto/selenium/skills_2/#_2')
# time.sleep(1)
# ele1 = driver.find_element(By.CSS_SELECTOR,'#_3')
# driver.execute_script("arguments[0].scrollIntoView({block:'center',inline:'center'})",ele1)
# time.sleep(3)

#确认按钮
# driver.get('https://www.byhy.net/cdn2/files/selenium/test4.html')
# driver.find_element(By.CSS_SELECTOR,'#b1').click()

# time.sleep(3)

# print(driver.switch_to.alert.text)
# driver.switch_to.alert.accept()
# time.sleep(3)

# driver.find_element(By.CSS_SELECTOR,'#b2').click()
# driver.switch_to.alert.dismiss()
# time.sleep(3)

# driver.find_element(By.CSS_SELECTOR,'#b3').click()
# driver.switch_to.alert.send_keys('我要找工作')
# driver.switch_to.alert.accept()
# time.sleep(3)

# driver.get_screenshot_as_file('1.png')

driver.get('https://tinypng.com/')
p_path = '/Users/show/Desktop/截屏2023-03-27 02.57.01.png'
driver.find_element(By.CSS_SELECTOR,'#upload-dropbox-zone>input').send_keys(p_path)

time.sleep(3)
driver.find_element(By.CSS_SELECTOR,'.download-all-button').click()

time.sleep(3)